--
-- Author: ping.wang
-- Date: 2019-05-15 12:35:09
--
-- DailyworkflowRender
--

local ClassRef = app.mvc.createRenderClass(...)
--data =
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.DailyTimelineListRender))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

--
function ClassRef:init(data)
    self.super.init(self, data)
    self:setContentSize( self._ui.Panel:getContentSize() )
    self:refresh()
end

function ClassRef:refresh()
    if self._data then
        self:setVisible( true )
        local data = self._data
        self._ui.bg:setVisible((data.idx % 2) == 0)
        self._ui.time:setString(data.time)
        if data.inTimeRange then
            self._ui.time:setTextColor(cc.c3b(0,255,168))
            self._ui.line:setColor(cc.c3b(0,255,168))
        else
            self._ui.time:setTextColor(cc.c3b(255,255,132))
            self._ui.line:setColor(cc.c3b(255,255,132))
        end

    else
        self:setVisible( false )
    end
end

--设置使用节点 同一时间最多3个


function ClassRef:addTimelineBlock(blockNode, row)
    local str = string.format("Panel/Node_%s", row)
    local pNode = self._ui[str]
    pNode:addChild(blockNode)
end


function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef
